package com.Servlet;

import java.io.IOException;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.jdbc.Jdbc;

/**
 * Servlet implementation class class_remove
 */
@WebServlet("/class_remove")
public class class_remove extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public class_remove() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		response.getWriter().append("Served at: ").append(request.getContextPath());
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		String classname = request.getParameter("classname");
		String centername = request.getParameter("centername");
		String checktable = centername+classname+"check";
		String delete1 = "delete from class where centername='"+centername+"' and classname='"+classname+"' ";//删除classinfo中的内容
		String delete2 = "drop table "+checktable;//删除签到表格
		String delete3 = "delete from stu_class where centername='"+centername+"' and classname='"+classname+"'";
		Jdbc j1 = null;

		try {
			j1 = new Jdbc(delete1);
			j1 = new Jdbc(delete2);
			j1  =new Jdbc(delete3);    
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
        
		
		
		

		request.getRequestDispatcher("showsuccess.jsp").forward(request, response);
				
	}

}
